package com.paradogs.framework.core.utils;


import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: yumi
 * @date: 2023/2/16  21:17
 * @Description: TODO
 */
@Slf4j
public class BeanUtils extends org.springframework.beans.BeanUtils {


    /**
     * 包装类和基本数据类型映射
     */
    private static Map<Class<?>, Class<?>> primitiveAndWrap;

    private static Map<Class<?>, Class<?>> wrapAndPrimitive;

    static {
        primitiveAndWrap = new HashMap<>();
        wrapAndPrimitive = new HashMap<>();

        primitiveAndWrap.put(byte.class, Byte.class);
        primitiveAndWrap.put(short.class, Short.class);
        primitiveAndWrap.put(int.class, Integer.class);
        primitiveAndWrap.put(long.class, Long.class);
        primitiveAndWrap.put(float.class, Float.class);
        primitiveAndWrap.put(double.class, Double.class);
        primitiveAndWrap.put(char.class, Character.class);
        primitiveAndWrap.put(boolean.class, Boolean.class);

        primitiveAndWrap.entrySet().forEach(entry -> wrapAndPrimitive.put(entry.getValue(), entry.getKey()));


    }

    public static <T, V> V copy(T source, V target) {
       copyProperties(source, target);
       return target;
    }

}
